/*
 * @Author: @yzcheng
 * @Date: 2021-04-09 18:37:12
 * @Version: 1.0
 * @LastEditors: @yzcheng
 * @Description:
 * @LastEditTime: 2021-05-13 19:41:49
 */
import { dataDictionary } from '@/api/line'
const line: any = {
  namespaced: true,
  state: {
    taskInfo: {
      id: '',
    },
    OrgNodeId:'',
    dictCodeList: null
  },
  mutations: {
    saveDictCodeList(state: any, payload: any) {
      state.dictCodeList = payload
    },
  },
  actions: {
    async getDictCodeList({ commit }: any, payload: any) {
      const rst = await dataDictionary(payload)
      const data = rst.data.data
      const obj = {}
      for (const key in data) {
        obj[key] = data[key].map((item) => {
          item.value = item.id
          item.label = item.itemText
          return item
        })
      }
      commit('saveDictCodeList', obj)
    },
    // getBdRoute({ state }: any): void {
    //   getBdRoute({
    //     method: 'get',
    //   }).then((res) => {
    //     state.lineData = res?.data?.data
    //   })
    // },
    // createLine({ state }: any, payload: any): void {
    //   getBdRoute({
    //     method: 'post',
    //     data: payload,
    //   }).then((res) => {
    //     state.lineData = res?.data?.data
    //   })
    // },
    // async deleteBdRoute({ store }: any, payload: any): Promise<void> {
    //   const rst = await deleteBdRoute(payload)
    //   if (rst.data.code === 200) {
    //     store.dispatch('getBdRoute')
    //   }
    // },
  },
}

export default line
